﻿/*
 * @author: wizardc
 */

using Dou.Resource;
using DouEditor.Utils;
using UnityEditor;
using UnityEngine;

namespace DouEditor.Resource.HotFixed
{
    /// <summary>
    /// 创建版本文件
    /// 版本文件会内置到安装包中，主副版本更改时需要重新装包，热更版本是未热更时的基本版本
    /// </summary>
    public class GenVersionFile
    {
        private const string Path = "Assets/Resources/Version.asset";
        
        public void Gen(BuildRule buildRule)
        {
            EditorUtil.CreateDirByFilePath(Path);
            var version = ScriptableObject.CreateInstance<VersionFile>();
            version.mainVersion = buildRule.mainVersion;
            version.subVersion = buildRule.subVersion;
            version.hotFixedVersion = buildRule.hotFixedVersion;
            AssetDatabase.CreateAsset(version, Path);
        }
    }
}
